<style>
    .xxpayPopupDiv .layui-form-label {
        width:120px !important;
        margin-left:1%;
    }
    .xxpayPopupDiv .layui-input-inline {
        width: 80% !important;
    }
</style>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-tab layui-tab-brief">
            <div class="layui-tab-content">
                <form class="layui-form center">
                    <div class="layui-form-item">
                        <label class="layui-form-label">域名地址</label>
                        <div class="layui-input-inline">
                            <input type="text" name="domainUrl" style="width: 30%" id="domainUrl" placeholder="域名地址（http://或https://开头）" required lay-verify="domainUrl" autocomplete="off" class="layui-input" />
                            <span style="font-size: x-small;color: red">地址如：http://www.baidu.com 需将该域名解析到pay项目,支付宝应用回调地址配置该域名</span>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">域名类型</label>
                        <div class="layui-input-inline" >
                            <input type="radio" name="domainType" title="仅支付宝打开" value="1" checked />
                            <input type="radio" name="domainType" title="仅获取支付宝用户ID" value="2" />
                            <input type="radio" name="domainType" title="都支持" value="3" checked />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">应用ID</label>
                        <div class="layui-input-inline">
                            <input type="text" name="appId" id="appId" placeholder="应用ID" class="layui-input" />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">应用私钥</label>
                        <div class="layui-input-inline">
                            <textarea name="appPrivateKey" id="appPrivateKey" placeholder="请输入应用私钥" class="layui-textarea"></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">支付宝公钥</label>
                        <div class="layui-input-inline">
                            <textarea name="AlipayPublicKey" id="AlipayPublicKey" placeholder="请输入支付宝公钥" class="layui-textarea"></textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">域名状态</label>
                        <div class="layui-input-inline" >
                            <input type="radio" name="domainStatus" title="启用" value="1" checked />
                            <input type="radio" name="domainStatus" title="停止" value="0" />
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-inline">
                            <button type="button" class="layui-hide xxpayYesBtn" lay-submit="" lay-filter="add">保存</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['form','table','util','admin',],function(){
        var form = layui.form
        , $ = layui.$
        , admin = layui.admin
        , layer = layui.layer 
        , element = layui.element
        , table = layui.table;

        element.render('breadcrumb', 'breadcrumb');//渲染导航信息

        // 当点击微信渠道配置按钮保存的时候
        form.on('submit(add)', function(data){

            /* 自定义验证规则 */
            form.verify({
                domainUrl: [/(http|https):\/\/([\w.]+\/?)\S*/, '必须以http,https开头,且需符合URL规范,检查格式是否正确']
            });

            admin.req({
                type: 'post',
                url: layui.setter.baseUrl + '/config/pay_domain/add', //模拟接口
                data: data.field,
                error: function(err){
                    layer.alert(err.msg,{title:"请求失败"})
                },
                success: function(res){
                    if(res.code == 0){
                        layer.alert(res.msg, {title: '保存成功'},function(index){
                            layer.closeAll(); //关闭所有弹层
                            layui.table.reload('tableReload', {page: {curr: 1}}); //调用业务弹层外表格重新加载
                        });
                    }
                }
            })
        })
        form.render();

    })
</script>